# @Time:2021/6/19 20:36
# @Author:5120195554王欣霏
# -*- coding = utf-8 -*-

import os
import pygame
from dialog import blit_text


# elder3的对话框显示
class Elder3Dialog(object):
    def __init__(self):
        img_path = os.path.join('../resource', 'img', 'elder', 'elder3-00002.tga')  # 头像路径
        temp_header = pygame.image.load(img_path)
        header_width = temp_header.get_width()
        header_height = temp_header.get_height()
        header = pygame.transform.scale(temp_header, (header_width, header_height))

        dialog_path = os.path.join('../resource', 'img', 'dialog', 'dialog.png')
        temp_dialog = pygame.image.load(dialog_path)
        dialog_width = temp_dialog.get_width() // 2
        dialog_height = temp_dialog.get_height() // 2
        dialog = pygame.transform.scale(temp_dialog, (dialog_width, dialog_height))

        font_path = os.path.join('../resource', 'font', 'newfont.TTF')  # 字体路径
        font = pygame.font.Font(font_path, 18)  # 第二个参数是字体大小

        text = "孙大圣，你这一去恐怕凶多吉少。 小的劝您三思啊。 " \
               "如果你执意要去 你可以去前面的 大姐 那里问问路。"
        blit_text(dialog, text, (20, 25), font)

        if header_height > dialog_height:
            height = header_height
        else:
            height = dialog_height
        width = header_width + dialog_width
        self.surface = pygame.Surface((width, height))
        self.surface.set_colorkey((0, 0, 0))
        self.surface.blit(header, (0, 0))
        self.surface.blit(dialog, (header_width, 0))
